//app左侧导航
$('.sidebar-app').on('click','.list-group-item',function(){
	$('.sidebar-app').find('.list-group-item').removeClass('active');
	$(this).addClass('active');
});
//选择框
$('input').iCheck({
	checkboxClass: 'icheckbox_square-red',
	radioClass: 'iradio_square-red'
});

//select init
$('.selectpicker').selectpicker();
//$('.bootstrap-select,.selectpicker,.myfadeIn').css({'opacity':1});
//datetime
$('.hasdate').datetimepicker({
	lang:'ch',
	format:'Y-m-d H:i',
	yearStart:2015,
	yearEnd:2050
});




/*app 图标高度*/
function lineHeight(){
	var winH,titleH,appListH;
	winH = $(window).height();
	titleH = $('.page-header').outerHeight();
	appListH = (winH - titleH - 71);
	$('.app-list').css({'height':appListH+'px'});
}

function listgroupsidebarH(){
	var eleH1,eleH2,eleH3,eleH4,eleH5,targetH;
	eleH1 = $('.sidebar').height();	
	targetH = eleH1-24;
	$('.sidebar-app>dl').css({'height':targetH+'px'});	

}
$(function(){
    lineHeight();
    listgroupsidebarH();
    $(window).on('resize',function(){
    	lineHeight();
    	listgroupsidebarH();
    });
});
		
//tree
$('.app-tree li:has(ul)').addClass('parent_li');
 $('.app-tree li > span').on('click', function (e) {   		 	
 	$('.app-tree li span').removeClass('active');
 	$(this).addClass('active');
 	
	var children = $(this).parent('li.parent_li').find(' > ul > li');
	if (children.is(":visible")) {
   	 	children.hide();
    	$(this).find('i').addClass('gicon-plus-sign').removeClass('gicon-minus-sign');
    	$(this).find('b').addClass('gicon-folder-close').removeClass('gicon-folder-open');
        } else {		
            children.show();		
            $(this).find('i').addClass('gicon-minus-sign').removeClass('gicon-plus-sign');		
            $(this).find('b').addClass('gicon-folder-open').removeClass('gicon-folder-close');		
        }		
        e.stopPropagation();		
  });


//弹窗-新增商品
$('.btn-addgmnew').on('click',function(){
	$(this).addClass('active');
	$('.popup-gmnew').show();
});
$('.popup-gmnew').on('click','.popup-close',function(){
	$('.btn-addgmnew').removeClass('active');
})

//弹窗-新增类别
$('.btn-addcategory').on('click',function(){
	$(this).addClass('active');
	$('.popup-category').show();
});
$('.popup-category').on('click','.popup-close',function(){
	$('.btn-addcategory').removeClass('active');
})

